package client

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/data/binding"
)

type LocalApp struct {
	app fyne.App

	welcomeWindow  fyne.Window
	registerWindow fyne.Window
	loginWindow    fyne.Window
	MainWindow     fyne.Window                  //主界面
	chatWindow     map[string]fyne.Window       //一个朋友一个Window
	chatList       map[string]binding.BytesList //一个朋友一个ByteList

	client *Client
}

func BuildApp() *LocalApp {
	la := new(LocalApp)

	app := app.New()
	la.app = app

	la.welcomeWindow = la.BuildWelcome()
	la.registerWindow = la.BuildRegister()
	//la.loginWindow = la.BuildLogin()

	la.client = NewClient()
	la.client.Run()

	return la
}

func (la *LocalApp) Run() {
	la.welcomeWindow.ShowAndRun()
}
